Page({
    /**
     * 页面的初始数据
     */
    data: {
        ctx: {},
        position: "front",
        iknow: false,
        temPhoto: "",
        list: [{
            name: '模拟风格',
            id: 1,
            select: false
            
        }, {
            name: '智能美学判断',
            id: 2,
            select: true,
            url:"../znmxpd/index"
        }, {
            name: '模拟整形',
            id: 3,
            select: false
        }],
        id: "2",
        agressTxt: "[ 我们将保障您的个人信息安全,不会泄露您的拍摄照片 ]",
        screenWidth:""
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        wx.getSystemInfo({
            success: res => {
                // console.log(res)
                this.setData({
                    CaHeight: res.screenHeight - 157 + "px",
                    statusBarHeight: res.statusBarHeight,
                    screenWidth:res.screenWidth
                })
            },
        })
        let ctx = wx.createCameraContext()
        this.setData({
            ctx: ctx
        })
    },
    cancel(){
        this.setData({
            isMN:false
        })
    },
    exchange(e) {
        let list = JSON.parse(JSON.stringify(this.data.list))

        list.forEach(item => {
            item.select = false
        })
        list.forEach(item => {
            if (item.id == e.currentTarget.dataset.item.id) {
                item.select = true
            }
        })
        this.setData({
            list: list,
            id: e.currentTarget.dataset.item.id
        })
    },
    cancelNotice() {
        this.setData({
            iknow: false
        })
    },
    naviback() {
        wx.navigateBack({
            delta: 1,
        })
    },
    // 预览
    previewImg() {
        wx.previewImage({
            urls: [this.data.temPhoto],
        })
    },

   
    openXC(){  
            wx.chooseImage({
                count: 1,
                sourceType: ["album"],
                sizeType: ['original', 'compressed'],
                success: res1 => {
                    getApp().globalData.tempPhoto=res1.tempFilePaths[0]
                    this.setData({
                        temPhoto: res1.tempFilePaths[0]
                    })        
                            this.goJump()            
                }
            })
        
    },


    takePhoto() {
     
        let ctx = this.data.ctx
        ctx.takePhoto({
            quality: 'normal',
            success: (res) => {
                let url = res.tempImagePath;
                
                // 获取 智能美学判断 坐标缩放比
                getApp().globalData.pie= res.width/this.data.screenWidth

                console.log('resPhoto',res)
                this.setData({
                    temPhoto: res.tempImagePath
                })
                getApp().globalData.tempPhoto=url 
                this.goJump(res.height)
            }
        })
    },
    goJump(height){
        if(this.data.id == 3){
            

            wx.navigateTo({
                url: '../mnzx/index',
              })
        }

        if(this.data.id == 1){
            wx.navigateTo({
              url: '../mnfg/index',
            })
        }

        if(this.data.id == 2){
            wx.navigateTo({
              url: '../znmxpd/index?height='+height,
            })
        }
       
    }

  
  

})